package cn.example.vip.mall.canal.spring;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class SpringContext implements ApplicationContextAware {
	private static ApplicationContext applicationContextBean;
	
	public static <T>T getBean(Class clazz){
		return applicationContextBean.getBean((Class<T>)clazz);
	}
	
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		applicationContextBean = applicationContext;
	}
}
